package com.dana.friend.controller.user;


import com.core.controller.BaseController;
import com.core.domain.Result;
import com.core.domain.TableDataInfo;
import com.dana.friend.domain.exam.dto.QueryExamDTO;
import com.dana.friend.domain.user.dto.UserExamDTO;
import com.dana.friend.service.user.IUserExamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user/exam")
public class UserExamController extends BaseController {
    @Autowired
    private IUserExamService userExamService;

    /**
     * 用户报名竞赛
     * @param userExamDTO 报名的竞赛id
     * @return 成功or失败
     */
    @PostMapping("/enter")
    public Result<Void> enter(@RequestBody UserExamDTO userExamDTO){

        return toResult(userExamService.enter(userExamDTO.getExamId()));
    }


    /**
     * 我的竞赛
     */
    @GetMapping("/list")
    public TableDataInfo list(QueryExamDTO queryExamDTO) {
        return userExamService.getList(queryExamDTO);
    }
}
